<?php


namespace App\Http\Controllers\Api;

use App\Constants\TcmAromaConstant;
use App\Models\TcmAroma;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Models\Tcmclassic;
use App\Models\TcmFoodDetail;
use App\Models\TcmMedicineddietDetail;
use App\Models\TcmDrugDetail;
use App\Models\TcmPrescriptionDetail;
use App\Models\TcmMedicineDetail;
use App\Models\TcmDongqipointDetail;
use App\Models\TcmCaseDetail;
use App\Models\TcmDoctorDetail;
use App\Models\TcmTeaDetail;

class TcmController extends Controller
{
    /**
     * 主导航
     * @return Array
     */
    public function main_nav()
    {
        $list = Tcmclassic::with(['jump' => function ($q) {
            return $q->where('is_show', 1);
        }])->where(['status' => 1])
            ->orderBy('sort', 'desc')
            ->select('id', 'name', 'module', 'images', 'url', 'jump_tag_id')
            ->get();
        return $this->success('success', $list);
    }

    /**
     * 食材属性
     * @return Array
     */
    public function tcm_food_attr(Request $request)
    {
        //性
        $natures = ['寒', '凉', '平', '温', '热'];
        //味
        $flavors = ['酸', '涩', '甘', '苦', '辛', '咸', '淡'];
        //功效
        $effects = ['解表', '清热', '祛痰止咳', '祛湿', '理气', '活血', '补气', '补血', '补阴', '补阳', '温理', '消食', '润下', '止血', '固涩', '安神', '驱虫', '平肝'];
        //类别
        $classification = ['米面', '蔬菜', '肉类', '果实', '豆类', '根茎', '调料', '菌菇', '瓜茄', '种仁', '糖类', '油类', '花类', '饮品及奶制品', '皮壳', '蛋类'];

        $list = [];

        $list['0']['name'] = '性';
        $list['0']['code'] = 'natures';
        $list['0']['row'] = $natures;
        $list['1']['name'] = '味';
        $list['1']['code'] = 'flavors';
        $list['1']['row'] = $flavors;
        $list['2']['name'] = '功效';
        $list['2']['code'] = 'effects';
        $list['2']['row'] = $effects;
        $list['3']['name'] = '类别';
        $list['3']['code'] = 'classification';
        $list['3']['row'] = $classification;

        return $this->success('success', $list);
    }

    /**
     * 食材列表内容
     * @return Array
     */
    public function tcm_food_list(Request $request)
    {
        $name = $request->input('name') ?? '';
        $natures = $request->input('natures') ?? '';
        $flavors = $request->input('flavors') ?? '';
        $effects = $request->input('effects') ?? '';
        $classification = $request->input('classification') ?? '';

        $select = ['id', 'name', 'picture', 'classification'];
        $query = TcmFoodDetail::query();

        if ($natures) {
            $natures_arr = explode(',', $natures);
//            $query->whereIn('natures', $natures_arr);
            foreach ($natures_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`natures`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`natures`, '%s')", '"'.$item.'"'));
            }
        }
        if ($flavors) {
            $flavors_arr = explode(',', $flavors);
//            $query->whereIn('flavors', $flavors_arr);
            foreach ($flavors_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`flavors`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`flavors`, '%s')", '"'.$item.'"'));
            }
        }
        if ($effects) {
            $effects_arr = explode(',', $effects);
//            $query->whereIn('effects', $effects_arr);
            foreach ($effects_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"'));
            }
        }
        if ($classification) {
            $classification_arr = explode(',', $classification);
            $query->whereIn('classification', $classification_arr);
        }

        if ($name) {
            $query->where('name', 'like', '%' . $name . '%');
        }

        $query->select($select);
        $list = $query->orderBy('id', 'asc')->paginate();
        return $this->_success([
            'list' => $list->items()
        ]);
    }

    /**
     * 药膳属性
     * @return Array
     */
    public function tcm_medicineddiet_attr(Request $request)
    {
        //出处
        $source = ['圣济总录', '太平圣惠方', '饮膳正要', '食医心鉴', '遵生八笺', '食疗养老方', '食鉴草本', '金匮要略'];
        //类别
        $classification = ['茶', '汤', '粥', '羹', '膏', '饼', '酒', '面', '肉', '素', '其他'];

        $list = [];
        $list['0']['name'] = '出处';
        $list['0']['code'] = 'source';
        $list['0']['row'] = $source;
        $list['1']['name'] = '分类';
        $list['1']['code'] = 'classification';
        $list['1']['row'] = $classification;
        return $this->success('success', $list);
    }

    /**
     * 药膳列表内容
     * @return Array
     */
    public function tcm_medicineddiet_list(Request $request)
    {
        $name = $request->input('name') ?? '';
        $source = $request->input('source') ?? '';
        $classification = $request->input('classification') ?? '';

        $select = ['id', 'name', 'picture', 'source'];
        $query = TcmMedicineddietDetail::query();

        if ($source) {
            $source_arr = collect(explode(',', $source))->map(function ($item){
                return sprintf('《%s》', $item);
            })->all();

            $query->whereIn('source', $source_arr);
        }
        if ($classification) {
            $classification_arr = explode(',', $classification);
            $query->whereIn('classification', $classification_arr);
        }

        if ($name) {
            $query->where('name', 'like', '%' . $name . '%');
        }

        $query->select($select);
        $list = $query->orderBy('id', 'asc')->paginate();
        return $this->_success([
            'list' => $list->items()
        ]);
    }

    /**
     * 药材属性
     * @return Array
     */
    public function tcm_drug_attr(Request $request)
    {
        //性
        $natures = ['寒', '凉', '平', '温', '热'];
        //味
        $flavors = ['酸', '涩', '甘', '苦', '辛', '咸', '淡'];
        //功效
        $effects = ['解表药', '清热药', '祛痰止咳药', '祛湿药', '理气药', '活血药', '补气药', '补血药', '补阴药', '补阳药', '温理药', '消食药', '润下药', '止血药', '固涩药', '安神药', '驱虫药', '平肝熄风药'];
        //三品
        $mishina = ['上品', '中品', '下品'];

        $list = [];
        $list['natures'] = $natures;
        $list['flavors'] = $flavors;
        $list['effects'] = $effects;
        $list['mishina'] = $mishina;

        $list = [];
        $list['0']['name'] = '性';
        $list['0']['code'] = 'natures';
        $list['0']['row'] = $natures;

        $list['1']['name'] = '味';
        $list['1']['code'] = 'flavors';
        $list['1']['row'] = $flavors;

        $list['2']['name'] = '功效';
        $list['2']['code'] = 'effects';
        $list['2']['row'] = $effects;

        $list['3']['name'] = '三品';
        $list['3']['code'] = 'mishina';
        $list['3']['row'] = $mishina;

        return $this->success('success', $list);
    }

    /**
     * 药材列表内容
     * @return Array
     */
    public function tcm_drug_list(Request $request)
    {
        $name = $request->input('name') ?? '';
        $natures = $request->input('natures') ?? '';
        $flavors = $request->input('flavors') ?? '';
        $effects = $request->input('effects') ?? '';
        $mishina = $request->input('mishina') ?? '';

        $select = ['id', 'name', 'picture', 'effects'];
        $query = TcmDrugDetail::query();

        if ($natures) {
            $natures_arr = explode(',', $natures);
//            $query->whereIn('natures', $natures_arr);
            foreach ($natures_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`natures`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`natures`, '%s')", '"'.$item.'"'));
            }
        }
        if ($flavors) {
            $flavors_arr = explode(',', $flavors);
//            $query->whereIn('flavors', $flavors_arr);
            foreach ($flavors_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`flavors`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`flavors`, '%s')", '"'.$item.'"'));
            }
        }
        if ($effects) {
            $effects_arr = explode(',', $effects);
//            $query->whereIn('effects', $effects_arr);
            foreach ($effects_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"'));
            }
        }
        if ($mishina) {
            $mishina_arr = explode(',', $mishina);
            $query->whereIn('mishina', $mishina_arr);
        }

        if ($name) {
            $query->where('name', 'like', '%' . $name . '%');
        }

        $query->select($select);
        $list = $query->orderBy('id', 'asc')->paginate();

        foreach ($list as $key => $val) {
            $list[$key]['effects'] = json_decode($val->effects, true);
        }

        return $this->_success([
            'list' => $list->items()
        ]);
    }

    /**
     * 方剂属性
     * @return Array
     */
    public function tcm_prescription_attr(Request $request)
    {
        //出处
        $source = ['万病回春',
            '三因极一病证方论',
            '世医得效方',
            '东垣试效方',
            '严氏济生方',
            '中藏经',
            '丹溪心法',
            '产育宝庆集',
            '仁斋直指方论附遗',
            '传信适用方',
            '伤寒六书',
            '伤寒瘟疫条辨',
            '伤寒论',
            '保婴撮要',
            '傅青主女科',
            '傅青主男科',
            '儒门事亲',
            '先醒斋医学广笔记',
            '兰台轨范',
            '兰室秘藏',
            '内外伤辨惑论',
            '内科摘要',
            '冯氏锦囊秘录',
            '医便',
            '医原',
            '医学入门',
            '医学发明',
            '医学启源',
            '医学心悟',
            '医学正传',
            '医学纲目',
            '医学衷中参西录',
            '医宗金鉴',
            '医效秘传',
            '医方类聚',
            '医方考',
            '医方集解',
            '医林改错',
            '医理真传',
            '医贯',
            '千金翼方',
            '口齿类要',
            '古今名医方论',
            '古今图书集成医部全录',
            '周慎斋遗书',
            '喉科秘诀',
            '四圣心源',
            '备急千金要方',
            '外台秘要',
            '外科全生集',
            '外科发挥',
            '外科正宗',
            '外科证治全生集',
            '太平惠民和剂局方',
            '奇效良方',
            '寿世保元',
            '小儿药证直诀',
            '幼幼集成',
            '幼科发挥',
            '御药院方',
            '慎柔五书',
            '摄生众妙方',
            '时方歌括',
            '明医指掌',
            '易简方',
            '普济方',
            '普济本事方',
            '景岳全书',
            '本草纲目',
            '本草衍义',
            '杂病证治新义',
            '杨氏家藏方',
            '柳州医话',
            '校注妇人良方',
            '正体类要',
            '此事难知',
            '沈氏尊生书',
            '洞天奥旨',
            '洪氏集验方',
            '温热经纬',
            '温疫论',
            '温病条辨',
            '灵枢',
            '玉机微义',
            '疫疹一得',
            '症因脉治',
            '眼科秘诀',
            '石室秘录',
            '笔花医镜',
            '类编朱氏集验医方',
            '素问病机气宜保命集',
            '红炉点雪',
            '脾胃论',
            '证治准绳',
            '证治要诀类方',
            '辅行诀脏腑用药法要',
            '辨证录',
            '重楼玉钥',
            '重订广温热论',
            '重订通俗伤寒论',
            '金匮翼',
            '金匮要略',
            '金匮钩玄',
            '银海精微',
            '阎氏小儿方论',
            '阴证略例',
            '集验背疽方',
            '霍乱论',
            '韩氏医通',
            '验方新编',
            '鲁府禁方',
            '麻疹全书',
            '黄帝素问宣明论方'];
        //功效
        $effects = ['交通心肾剂',
            '凉开剂',
            '利水渗湿剂',
            '化湿和胃剂',
            '和解少阳剂',
            '回阳救逆剂',
            '固崩止带剂',
            '寒下剂',
            '平息內风剂',
            '托里透脓剂',
            '扶正解表剂',
            '攻补兼施剂',
            '散结消痈剂',
            '止血剂',
            '气血两清剂',
            '气血双补剂',
            '治风化痰剂',
            '活血祛瘀剂',
            '消食化滞剂',
            '润下剂',
            '涩精止遗剂',
            '涩肠固脱剂',
            '清宣外燥剂',
            '清气分热剂',
            '清热化痰剂',
            '清热导腑剂',
            '清热祛湿剂',
            '清热解毒剂',
            '清脏腑热剂',
            '清营凉血剂',
            '清虚热剂',
            '温下剂',
            '温中祛寒剂',
            '温化寒湿剂',
            '温化寒痰剂',
            '温经散寒剂',
            '滋润内燥剂',
            '燥湿化痰剂',
            '疏散外风剂',
            '祛暑利湿剂',
            '祛暑益气剂',
            '祛暑解表剂',
            '祛湿化浊剂',
            '祛风胜湿剂',
            '行气丸',
            '行气剂',
            '补养安神剂',
            '补气剂',
            '补血剂',
            '补阳剂',
            '补阴剂',
            '解表攻里剂',
            '解表清里剂',
            '调和寒热剂',
            '调和肝脾剂',
            '辛凉解表剂',
            '辛温解表剂',
            '逐水剂',
            '重症安神剂',
            '阴阳并补剂',
            '降气剂',
            '降气汤',
            '驱虫剂'];

        $list = [];
        $list['0']['name'] = '出处';
        $list['0']['code'] = 'source';
        $list['0']['row'] = $source;
        $list['1']['name'] = '功效';
        $list['1']['code'] = 'effects';
        $list['1']['row'] = $effects;
        return $this->success('success', $list);
    }

    /**
     * 方剂列表内容
     * @return Array
     */
    public function tcm_prescription_list(Request $request)
    {
        $name = $request->input('name') ?? '';
        $source = $request->input('source') ?? '';
        $effects = $request->input('effects') ?? '';

        $select = ['id', 'name', 'picture', 'source'];
        $query = TcmPrescriptionDetail::query();

        if ($source) {
            $source_arr = collect(explode(',', $source))->map(function ($item){
                return sprintf('《%s》', $item);
            })->all();
            $query->whereIn('source', $source_arr);
        }
        if ($effects) {
            $effects_arr = explode(',', $effects);
//            $query->whereIn('effects', $effects_arr);
            foreach ($effects_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"'));
            }
        }

        if ($name) {
            $query->where('name', 'like', '%' . $name . '%');
        }


        $query->select($select);
        $list = $query->orderBy('id', 'asc')->paginate();
        return $this->_success([
            'list' => $list->items()
        ]);
    }

    /**
     * 中成药属性
     * @return Array
     */
    public function tcm_medicine_attr(Request $request)
    {

        //功效
        $effects = ['健胃祛暑',
            '健脾养血',
            '健脾和胃',
            '健脾益气',
            '养心安神',
            '养血理气',
            '养血疏肝',
            '凉血止血',
            '化浊降脂',
            '化痰利咽',
            '化痰开窍',
            '化瘀宽胸',
            '化瘀通淋',
            '化瘀通脉',
            '宣肺通窍',
            '平肝息风',
            '扶正祛湿',
            '扶正解表',
            '散寒止咳',
            '活血化瘀',
            '活血祛瘀',
            '活血通络',
            '消肿利水',
            '消肿散结',
            '消食导滞',
            '润肠通便',
            '润肺止咳',
            '清热利湿',
            '清热开窍',
            '清热散风',
            '清热泻火',
            '清热消肿',
            '清热祛湿',
            '清热解毒',
            '清热通窍',
            '清热除湿',
            '清肝解毒',
            '清肺平喘',
            '清肺止咳',
            '温中健脾',
            '温补肾阳',
            '滋肾养肝',
            '滋阴养肝',
            '滋阴安神',
            '滋阴补肾',
            '滋阴降火',
            '理气止痛',
            '理气活血',
            '疏散外风',
            '疏肝和胃',
            '疏肝解郁',
            '益气养血',
            '益气养阴',
            '益气复脉',
            '益气活血',
            '益肾通淋',
            '祛风化瘀',
            '祛风通络',
            '舒筋通络',
            '补肾缩尿',
            '表里双解',
            '解表祛暑',
            '软坚散结',
            '辛凉解表',
            '辛温解表',
            '通淋消石'];

        $list = [];
        $list['0']['name'] = '功效';
        $list['0']['code'] = 'effects';
        $list['0']['row'] = $effects;
        return $this->success('success', $list);
    }

    /**
     * 中成药列表内容
     * @return Array
     */
    public function tcm_medicine_list(Request $request)
    {
        $name = $request->input('name') ?? '';
        $source = $request->input('source') ?? '';
        $effects = $request->input('effects') ?? '';

        $select = ['id', 'name', 'picture', 'effects'];
        $query = TcmMedicineDetail::query();

        if ($effects) {
            $effects_arr = explode(',', $effects);
//            $query->whereIn('effects', $effects_arr);
            foreach ($effects_arr as $key => $item) {
                $key == 0  ?
                    $query->whereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"')) :
                    $query->orWhereRaw(sprintf("JSON_CONTAINS(`effects`, '%s')", '"'.$item.'"'));
            }
        }

        if ($name) {
            $query->where('name', 'like', '%' . $name . '%');
        }

        $query->select($select);
        $list = $query->orderBy('id', 'asc')->paginate();
        foreach ($list as $key => $val) {
            $list[$key]['effects'] = json_decode($val->effects, true);
        }

        return $this->_success([
            'list' => $list->items()
        ]);
    }

    /**
     * 医案列表内容
     * @return Array
     */
    public function tcm_case_list(Request $request)
    {
        $name = $request->input('name') ?? '';
        $doctor = $request->input('doctor') ?? '';
        $select = ['id', 'name', 'doctor', 'shareImg', 'symptoms', 'content'];
        $query = TcmCaseDetail::query();

        if ($name) {
            $query->where('name', 'like', '%' . $name . '%');
        }

        if ($doctor) {
            $query->where('doctor', $doctor);
        }

        $query->select($select);
        $list = $query->orderBy('id', 'asc')->paginate();

        foreach ($list as $key => $val) {
            $list[$key]['symptoms'] = json_decode($val->symptoms, true);
        }

        return $this->_success([
            'list' => $list->items()
        ]);
    }

    /**
     * 医家字母
     * @return Array
     */
    public function tcm_doctor_firstLetter(Request $request)
    {
        $list = TcmDoctorDetail::query()
            ->groupBy('firstLetter')
            ->orderBy('firstLetter', 'asc')
            ->pluck('firstLetter');
        return $this->success('success', $list);
    }

    /**
     * 医家列表内容
     * @return Array
     */
    public function tcm_doctor_list(Request $request)
    {
        $list = TcmDoctorDetail::query()->groupBy('firstLetter')->select(['firstLetter'])->orderBy('firstLetter', 'asc')->get();
        foreach ($list as $key => $val) {
            $doctor = TcmDoctorDetail::query()->where('firstLetter', $val->firstLetter)->select(['id', 'name', 'picture', 'caseCount'])->orderBy('id', 'asc')->get();
            $list[$key]['doctor'] = $doctor;
        }

        return $this->success('success', $list);
    }

    /**
     * 董氏奇穴列表内容
     * @return Array
     */
    public function tcm_dongqipoint_list(Request $request)
    {
        $list = TcmDongqipointDetail::query()->groupBy('position')->select(['position'])->orderBy('position', 'asc')->get();
        foreach ($list as $key => $val) {
            $row = TcmDongqipointDetail::query()->where('position', $val->position)->select(['id', 'name'])->orderBy('id', 'asc')->get();
            $list[$key]['row'] = $row;
        }

        return $this->success('success', $list);
    }

    /**
     * 茶属性
     * @return Array
     */
    public function tcm_tea_attr(Request $request)
    {
        //茶类
        $teaCategory = ['乌龙茶', '白茶', '红茶', '绿茶', '花茶', '黄茶', '黑茶'];
        //产地
        $origin = ['重庆', '江苏', '浙江', '安徽', '福建'];

        $list = [];
        $list['0']['name'] = '茶类';
        $list['0']['code'] = 'teaCategory';
        $list['0']['row'] = $teaCategory;
//        $list['1']['name'] = '产地';
//        $list['1']['code'] = 'origin';
//        $list['1']['row'] = $origin;

        return $this->success('success', $list);
    }

    /**
     * 茶列表内容
     * @return Array
     */
    public function tcm_tea_list(Request $request)
    {
        $name = $request->input('name') ?? '';
        $teaCategory = $request->input('teaCategory') ?? '';
        $origin = $request->input('origin') ?? '';

        $select = ['id', 'name', 'picture', 'teaCategory'];
        $query = TcmTeaDetail::query();

        if ($teaCategory) {
            $teaCategory_arr = explode(',', $teaCategory);
            $query->whereIn('teaCategory', $teaCategory_arr);
        }
        if ($origin) {
            $query->where('origin', $origin);
        }

        if ($name) {
            $query->where('name', 'like', '%' . $name . '%');
        }

        $query->select($select);
        $list = $query->orderBy('id', 'asc')->paginate();
        return $this->_success([
            'list' => $list->items()
        ]);
    }

    /**
     * 中医模块详情
     * @return Array
     */
    public function tcm_detail(Request $request)
    {
        $id = $request->input('id') ?? '';
        $modules = $request->input('modules') ?? '';

        if (empty($id) || empty($modules)) {
            return $this->success('success', []);
        }
        switch ($modules) {
            case 'food':
                $query = TcmFoodDetail::query();
                break;
            case 'medicineddiet':
                $query = TcmMedicineddietDetail::query();
                break;
            case 'drug':
                $query = TcmDrugDetail::query();
                break;
            case 'prescription':
                $query = TcmPrescriptionDetail::query();
                break;
            case 'medicine':
                $query = TcmMedicineDetail::query();
                break;
            case 'dongqipoint':
                $query = TcmDongqipointDetail::query();
                break;
            case 'case':
                $query = TcmCaseDetail::query();
                break;
            case 'doctor':
                $query = TcmDoctorDetail::query();
                break;
            case 'tea':
                $query = TcmTeaDetail::query();
                break;
            case 'aroma':
                $query = TcmAroma::query();
                break;
        }

        if (empty($query)) {
            return response()->json([]);
        }
        $info = $query->where('id', $id)->first();
        if (!empty($info)) {
            $info = json_decode($info, true);
        }

        foreach ($info as $key => $val) {
            $checkJson = json_decode($val, true);
            if ($checkJson != null) {
                $info[$key] = $checkJson;
            }
            if ($val == "[]") {
                $info[$key] = [];
            }
        }

        return $this->success('success', $info);
    }

    // 香
    public function tcm_aroma_list(Request $request)
    {
        $name = $request->input('name');
        $class = array_filter(explode(',', $request->input('class')));
        $origin = array_filter(explode(',', $request->input('origin_label')));

        $list = TcmAroma::select(['id', 'name', 'class', 'img'])
            ->when($name, function ($q, $name) {
                return $q->where('name', 'like', '%' . $name . '%');
            })
            ->when($class, function ($q, $class) {
                return $q->whereIn('class', $class);
            })
            ->when($origin, function ($q, $origin) {
                foreach ($origin as $index => $v) {
                    $index == 0 ?
                        $q->whereRaw(sprintf('FIND_IN_SET("%s",REPLACE(origin_label, "/", "," ))', $v)) :
                        $q->orWhereRaw(sprintf('FIND_IN_SET("%s",REPLACE(origin_label, "/", "," ))', $v));
                }
            })
            ->paginate();

        return $this->_success($list->items());
    }

    public function tcm_aroma_condition()
    {
        $data = [
            ['name' => '香类', 'code' => 'class', 'row' => TcmAromaConstant::CLASS_MAP],
            ['name' => '产地', 'code' => 'origin_label', 'row' => TcmAromaConstant::ORIGIN_MAP],
        ];

        return $this->_success($data);
    }
}
